﻿Type.registerNamespace("BM");

BM.CulturalContext = function(data) {
    this.formattings = data.Formattings;
}

BM.CulturalContext.prototype = {
    getFormat: function(dataType) {
        var specificFormat = this.getSpecificFormat(dataType);
        if (specificFormat != null) {            
            return specificFormat;
        }        
        return this.getDefaultFormat();
    },

    getSpecificFormat: function(dataType) {
        for (var i = 0; i < this.formattings.length; i++) {
            var formatting = this.formattings[i];
            if (formatting.DataType == dataType) {
                return formatting.CultureInvariantFormat;
            }
        }

        return null;
    },

    getDefaultFormat: function(formattingType) {
        return this.getSpecificFormat(0);
    }
}